package com.woniuxy.controller;


import com.woniuxy.common.Result;
import com.woniuxy.entity.Resource;
import com.woniuxy.service.ResourceService;
import com.woniuxy.util.RedisUtil;
import io.lettuce.core.cluster.RedisAdvancedClusterAsyncCommandsImpl;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zz
 * @since 2023年06月21日
 */
@RestController
@RequestMapping("/resource")
@Api(tags = "资源权限相关接口")
public class ResourceController {

    @Autowired
    private RedisUtil redisUtil;
    @Autowired
    private ResourceService resourceService;

    @GetMapping("/getMenus")
    public Result getMenus(@RequestHeader String accessToken) throws Exception{
        Integer accountId = redisUtil.getUserIdByToken(accessToken);
        List<Resource> list =resourceService.getMenusById(accountId);
        return Result.success(200,"根据角色获取资源成功",list);
    }

}

